<template>
	<view class="headerLayout">
		<view class="left">
			<uni-icons type="left" size="22" @click="goBack()"></uni-icons>
		</view>
		<view class="center">
			<slot name="title"><text>标题</text></slot>
		</view>
		<view class="right">
			<slot name="icon">
				<!-- <uni-icons type="settings" size="22"></uni-icons> -->
			</slot>
		</view>
	</view>
</template>

<script setup>
	const goBack = () => {
		let pages = getCurrentPages();
		if (pages && pages.length > 1) {
			uni.navigateBack({
				delta: 1
			});
		} else {
			// history.back();
			uni.switchTab({
				url: "/pages/index/index"
			})
		}
	}
</script>

<style lang="scss" scoped>
	.headerLayout {
		display: flex;
		justify-content: space-between;
		align-items: center;
		height: calc(var(--status-bar-height) + 90rpx);
		position: fixed;
		top: 0;
		right: 0;
		left: 0;
		z-index: 9999;
		background-color: #fff;
		padding: 0 20rpx;
		box-shadow: 0 1px 8px rgba(0, 0, 0, 0.08);
		padding-top: var(--status-bar-height);

		.title {
			color: #000;
			font-weight: 700;
			font-size: 32rpx;
		}

		.right {
			color: $theme-color;
			font-size: 28rpx;
		}
	}
</style>